package com.ysstech.etfmanage.enums;

import java.util.Arrays;

import com.ysstech.common.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * ETF类型常量
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum EtfTypeEnum implements BaseEnum<Integer> {
    SINGLE_MARKET(1, "单市场"),
    CROSS_MARKET(2, "跨市场"),
    CENTRALIZED_SUBSCRIPTION(3, "集中申购");

    private final Integer code;
    private final String desc;

    public static EtfTypeEnum getEnum(Integer code) {
        return Arrays.stream(values()).filter(b -> b.code == code).findFirst().orElse(null);
    }

    public static String getEnumDesc(Integer code) {
        EtfTypeEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }
}
